package com.tmpt.controller.taglib;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.googlecode.genericdao.search.Search;
import com.tmpt.dto.PaginationDto;
import com.tmpt.dto.A1OperationlogDto;
import com.tmpt.dto.A1LogTypeDto;
import com.tmpt.service.IOperationlogService;

public class OperationlogTag {
	
	@Resource(name="operationlogService")
	private IOperationlogService  operationlogService;
	
	public List<A1LogTypeDto> queryLogTypeList()
	{
		return operationlogService.queryLogTypeAll();
	}
	
	public PaginationDto<A1OperationlogDto> queryOperationlogByLogType(Map<String,Object> paramMap)
	{
		String pageNoStr = (String)paramMap.get("pageNo");
		String pageSizeStr = (String)paramMap.get("pageSize");
		int pageNo=1;
		int pageSize=0;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
			pageNo = Integer.parseInt(pageNoStr);
		} catch (Exception e) {
			//System.out.println("convert String to int wrong, maybe it is the first page.");
		}

		Search search = new Search();
		search.setPage(pageNo-1);
		search.setMaxResults(pageSize);
		search.addSort("createDate", true);
		
		String StrSelectlogTypeId = (String)paramMap.get("selectlogTypeId"); 
		int logTypeId = 0;
		try {
			logTypeId = Integer.parseInt(StrSelectlogTypeId);
		} catch (Exception e) {
			//System.out.println("convert String to int wrong, maybe it is the first page.");
		}
		//System.out.println(logTypeId);
		if(logTypeId != 0) search.addFilterEqual("logType.id", logTypeId);	
		PaginationDto<A1OperationlogDto> pagination = operationlogService.paginationBySearch(search);	
		return pagination;
	}
}
